package fr.vahren.sriksal.business;

import fr.vahren.sriksal.business.exception.InternalErrorException;
import fr.vahren.sriksal.dao.ITaskProgressDao;

public interface ITaskProgressBusiness {

	/**
	 * @param taskProgressDao the taskProgressDao to set
	 */
	public abstract void setTaskProgressDao(ITaskProgressDao taskProgressDao);

	/**
	 * Creates a new task progress, with step=0.
	 * @param taskName Name of the task.
	 * @throws InternalErrorException
	 */
	public abstract void createTaskProgress(String taskName)
			throws InternalErrorException;

	/**
	 * Update progress information. For a task identified by its name, update
	 * the latest step finished. Put 100 if the task is complete. 0 is when no
	 * step has been completed.
	 * 
	 * @param taskName
	 *            Name of the task.
	 * @param step
	 *            The latest step completed. 0 if none, 100 if task complete.
	 * @throws InternalErrorException
	 *             If an error occurs while updating the database.
	 */
	public abstract void updateProgress(String taskName, int step)
			throws InternalErrorException;

	/**
	 * Gets the latest completed step of the task.
	 * 
	 * @param taskName
	 *            The task name.
	 * @return The latest step completed. 0 if none. 100 if task is complete.
	 * @throws InternalErrorException
	 *             If an error occurs when getting info from database.
	 */
	public abstract int getProgress(String taskName)
			throws InternalErrorException;

}